package com.company;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int N = sc.nextInt();

        // 特殊处理
        if (K < 0 || N < 0) return ;
        if (K == 0 && N == 0) {
            System.out.printf("%d %d", 0, 0);
            return;
        }

        int traceback = 0;
        // 判断
        while (N-- > 0 && K > 0){
            int step = sc.nextInt();
            if (step < K){
                K -= step;
            } else if (step - K == 0) {
                K -= step;
                break;
            } else {
                // step > K
                traceback += (step - K);
                K = step - K;
            }
        }

        if (N > 0){  // && K == 0
            System.out.printf("paradox");
        } else {
            // System.out.printf("%d %d", K, trackback);
            // case 通过率为 24% ....
            System.out.printf("%d %d", K, traceback);
        }
    }
}